import java.awt.Color;
import java.util.Random;

// class that maintains different attributes for a player,
// this class should not be used directly,
public class PLPlayer {
	String mName = null;
	Color mColor = null;
	
	public PLPlayer() {}
	public PLPlayer(String name) {SetName(name);}

	public boolean IsValid() {return mName.length() > 0;}	

	public String GetName() {return mName;}
	public void SetName(String name) {mName = name;}
	
	public Color GetColor() {
		if ( null == mColor) {
			Random r = new Random();
			mColor = new Color(r.nextInt(256), r.nextInt(256), r.nextInt(256));
		}
		return mColor;
	}
	
	public void SetColor(Color color) {mColor = color;}
		
	public float GenResponse(PLShape query, PLOutShape outResponse) {
		// this functioin is intentionally left blank
		return 0;
	}


	public static PLPlayer GetPlayerFromName(String name) {
		PLDebug.Warn("Player  %s", name);

		int nameCode = name.hashCode();
		
		if (nameCode == "UI".hashCode()) {
			return new PLPlayerUI();
		} else if (nameCode == "BasicShapes".hashCode()) {
			return new PLPlayerBasicShapes(name);
		}
		else if (PLFileUtils.Exists(PLFileUtils.GetFullDirPath(name))) {
			return new PLPlayerModel(name);
		}
		
		PLDebug.Err("Pattern %s unknown", name);
		return null;		
	}


}

